package com.jdwx.opengl.kotlin

fun printDouble(d: Double) { print(d) }


fun decimalDigitValue(c: Char): Int {
    if (c !in '0'..'9')
        throw IllegalArgumentException("Out of range")
    return c.toInt() - '0'.toInt() // 显式转换为数字
}

fun main(){

    val i = 1
    val d = 1.1
    val f = 1.1f

    printDouble(d)



    var a : Int? = 1;

    var b : String? = "xiaobai";

    var c : String?;

    if( b != null ){
        print( "!null" );
    }

    print( a );

    // 假想的代码，实际上并不能编译：
    val a1: Int = 1 // 一个装箱的 Int (java.lang.Integer)
    val b1: Long? = a1.toLong() // 隐式转换产生一个装箱的 Long (java.lang.Long)

    var a2 = 1;

    var a3 =  1 shl 2;

    print("a2:"+ a3 );

    var value = decimalDigitValue('2');

    print( value );


    val asc = Array(5) { i -> (i * i).toString() }

    asc.forEach { println(it) }

    //IntArray
    val x = intArrayOf(1, 2, 3)
    println( x[0] )

    println( asc[2] )

    x.forEach (fun(value: Int) {
        if (value == 0) return
        println(value)
    })

    var ass:String = "xiaobai";

    println("$ass.length的长度${ass.length}")


}


